| Visual Basic (Declaration) | |
|---|---|
Public Overloads Function Read( _ ByVal buffer() As Byte, _ ByVal offset As Integer, _ ByVal count As Integer, _ ByVal fill As Boolean _ ) As Integer | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As SegmentedStream Dim buffer() As Byte Dim offset As Integer Dim count As Integer Dim fill As Boolean Dim value As Integer value = instance.Read(buffer, offset, count, fill) | |
Parameters
- buffer
- The storage location for the received data.
- offset
- The zero-based position in the buffer at which to store the received data.
- count
- The exact number of bytes to read.
- fill
- Always true, use this version of Read to completely fill the buffer
Return Value
The total number of bytes read into the buffer. This will either be the value of the count parameter, or zero if the stream has closed.| Exception | Description |
|---|---|
| System.IO.IOException | Thrown when the stream is not Readable. |
| System.ArgumentNullException | Thrown when the receiving buffer is null. |
| System.ArgumentOutOfRangeException | Thrown when the offset is less than zero or when count is less than or equal to zero. |
| System.ArgumentException | Thrown when (offset + count) > buffer.Length. |
| System.IO.EndOfStreamException | Thrown when the end of the stream was found before the required byte count was received. When this occurs the Available property will indicate how much data may be read and the CanRead Property will return true. |
This method reads data from the stream and returns when the provided buffer is completely full or end of stream is reached. This method is a good way to read fixed-length data. An example of this is with HTTP chunking, which occurs when the server breaks up the HTTP response into fixed-size chunks. Each chunk is preceded with a hexidecimal value notifying the receiver of the size of the data chunk to follow. Initialize a byte array to this value, then call this method to fill the byte array.
Target Platforms: Microsoft .NET Framework 2.0